﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COFE.Data
{
    public partial class Entry : IEquatable<Entry>
    {
        public bool Equals(Entry other)
        {
            if (
                this.GetType().Equals(other.GetType()) &&
                this.ParsePath == other.ParsePath &&
                    this.PrimaryVolumeId == other.PrimaryVolumeId &&
                    this.SecondaryVolumeId == other.SecondaryVolumeId &&
                    this.FileAttributes == other.FileAttributes &&
                    this.COFEAttributes == other.COFEAttributes
                )
            {
                if (this is FolderEntry)
                {
                    FolderEntry otherEntry = other as FolderEntry;
                    FolderEntry thisEntry = this as FolderEntry;

                    if (
                        thisEntry.SubFolderCount == otherEntry.SubFolderCount &&
                        thisEntry.FileCount == otherEntry.FileCount
                        )
                        return true;
                }

                if (this is FileEntry)
                {
                    FileEntry otherEntry = other as FileEntry;
                    FileEntry thisEntry = this as FileEntry;

                    if (
                        thisEntry.Length == otherEntry.Length &&
                        thisEntry.LastWriteTimeUtc == otherEntry.LastWriteTimeUtc
                        )
                        return true;
                }

            }


            return false;
        }
    }
}
